const db = {};
const mysql = require('mysql');
const pool = mysql.createPool({
    connectionLimit: 10,
    host:'localhost',
    user:"root",
    password:"woaini.1.2",
    database:"orderdata"
    // host: '192.168.1.194',
    // port: 3306, // MySQL 默认端口为 3306
    // user: 'qwn',  //用户名
    // password: 'qwn123', //用户密码
    // database: 'orderdata',  //数据库
    // useConnectionPooling: true
});

db.query = function (sql, callback) {
    if (!sql) {
        callback();
        return;
    }
    pool.query(sql, function (err, rows, fields) {
        if (err) {
            console.log(err);
            callback(err, null);
            return;
        };
        callback(null, rows, fields);
    });
}
module.exports = db;